package com.gmail.bloim.serg.acm;

import java.util.HashSet;
import java.util.Set;

/**
 * User: Администратор
 * Date: 26.04.13
 * Time: 7:24
 */
class Line {
    public static double eps = 0.00001d;
    private final double a, b, c;
    Set<Point> points = new HashSet<Point>();

    public Line(Point p1, Point p2) {
        a = p2.y - p1.y;
        b = p1.x - p2.x;
        c = -a * p1.x - b * p1.y;
        points.add(p1);
        points.add(p2);
    }

    public boolean contains(Point point) {
        return points.contains(point);
    }

    public boolean match(Point point) {
        double res = a * point.x + b * point.y + c;
        if (res < 0)
            res = -res;
        if (res < eps)
            return true;
        return false;
    }

    public void add(Point point) {
        points.add(point);
    }

    public int pointSize() {
        return points.size();
    }
}
